/*************************************************************************
	> File Name: P8218.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-14 10:53:15
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 100000
long long arr[MAX_N + 5];

int main() {
    int n;
    cin >> n;
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        arr[i] = arr[i - 1] + x;
    }
    int k;
    cin >> k;
    while (k--) {
        int i, j;
        scanf("%d%d", &i, &j);
        printf("%lld\n", arr[j] - arr[i - 1]);
    }
    return 0;
}
